import random
random_number = random.randint(1, 100)
attempts = 0
while True:    
    guess = int(input("猜一个 1 到 100 之间的数字："))    
    attempts += 1
    if guess < random_number:
        print("猜小了！")    
    elif guess > random_number:
        print("猜大了！")    
    else:        
        print(f"恭喜你猜对了！你用了 {attempts} 次尝试。")        
        break